home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / mipsABI / examples / sup / atoo.c next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  1.5 KB  |  55 lines

  1. /*
  2.  * Copyright (c) 1991 Carnegie Mellon University
  3.  * All Rights Reserved.
  4.  * 
  5.  * Permission to use, copy, modify and distribute this software and its
  6.  * documentation is hereby granted, provided that both the copyright
  7.  * notice and this permission notice appear in all copies of the
  8.  * software, derivative works or modified versions, and any portions
  9.  * thereof, and that both notices appear in supporting documentation.
  10.  *
  11.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  12.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  13.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  14.  *
  15.  * Carnegie Mellon requests users of this software to return to
  16.  *
  17.  *  Software Distribution Coordinator   or   Software.Distribution@CS.CMU.EDU
  18.  *  School of Computer Science
  19.  *  Carnegie Mellon University
  20.  *  Pittsburgh PA 15213-3890
  21.  *
  22.  * any improvements or extensions that they make and grant Carnegie the rights
  23.  * to redistribute these changes.
  24.  */
  25. /*  atoo  --  convert ascii to octal
  26.  *
  27.  *  Usge:  i = atoo (string);
  28.  *    unsigned int i;
  29.  *    char *string;
  30.  *
  31.  *  Atoo converts the value contained in "string" into an
  32.  *  unsigned integer, assuming that the value represents
  33.  *  an octal number.
  34.  *
  35.  *  HISTORY
  36.  * 20-Nov-79  Steven Shafer (sas) at Carnegie-Mellon University
  37.  *    Rewritten for VAX.
  38.  *
  39.  */
  40.  
  41. unsigned int atoo(ap)
  42. char *ap;
  43. {
  44.     register unsigned int n;
  45.     register char *p;
  46.  
  47.     p = ap;
  48.     n = 0;
  49.     while(*p == ' ' || *p == '    ')
  50.         p++;
  51.     while(*p >= '0' && *p <= '7')
  52.         n = n * 8 + *p++ - '0';
  53.     return(n);
  54. }
  55.